package basic.study.leetcode;

/**
 * @ClassName Mid55
 * @Description 跳跃游戏
 * @Company inspur
 * @Author Kevin
 * @Date 2020/6/22 16:54
 * @Version 1.0
 */
public class Mid55 {
    class Solution {
        public boolean canJump(int[] nums) {
            int n = nums.length;
            int rightmost = 0;
            for (int i = 0; i < n; i++) {
                if (i <= rightmost) {
                    rightmost = Math.max(rightmost, i + nums[i]);
                    if (rightmost >= n-1) {
                        return true;
                    }
                }
            }
            return false;
        }
    }
}
